# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=kubectx
pkgver=0.9.4
pkgrel=5
pkgdesc="Faster way to switch between clusters and namespaces in kubectl"
url="https://kubectx.dev/"
license="Apache-2.0"
arch="all"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/ahmetb/kubectx/archive/v$pkgver/kubectx-$pkgver.tar.gz"

export GOPATH="$srcdir"
export GOFLAGS="$GOFLAGS -trimpath -modcacherw"

build() {
	for cmd in kubectx kubens; do
		go build \
			-ldflags="-s -w -X main.version=$pkgver" \
			-v -o bin/$cmd ./cmd/$cmd
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/kubectx bin/kubens -t "$pkgdir"/usr/bin

	install -Dm644 completion/kubectx.bash "$pkgdir"/usr/share/bash-completion/completions/kubectx
	install -Dm644 completion/kubens.bash "$pkgdir"/usr/share/bash-completion/completions/kubens
	install -Dm644 completion/kubectx.fish "$pkgdir"/usr/share/fish/completions/kubectx.fish
	install -Dm644 completion/kubens.fish "$pkgdir"/usr/share/fish/completions/kubens.fish
	install -Dm644 completion/kubectx.zsh "$pkgdir"/usr/share/zsh/site-functions/_kubectx
	install -Dm644 completion/kubens.zsh "$pkgdir"/usr/share/zsh/site-functions/_kubens
}

sha512sums="
edb5a05d5b32e486a227e8a4c98864a8dd1e0f3c325fd63a9c3f10ba3ca7a57420d3b1dda9d7674cdbf18fea9cfafbfabdc19c4e15ab1a2a18af967d8fd50997  kubectx-0.9.4.tar.gz
"
